package com.huadao.pda.data.http;

import io.reactivex.functions.Function;

/**
 * 登陆专用
 * 因为登陆返回的code和其他接口不一样，登陆返回的code0为成功，其他是1为成功
 * @param <T>
 */
public class HttpLoginFunction<T> implements Function<BaseLoginResponse<T>,T> {
    @Override
    public T apply(BaseLoginResponse<T> response) throws Exception {
        if (!response.isRequestSuccess()) {
            throw new ApiException(response.getCode(), String.valueOf(response.getMsg()));
        }
        return response.getData();
    }

}